home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13431 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can anyone HELP with variable delaration? Please?
  5. Date: Sat, 06 Apr 96 21:36:15 GMT
  6. Organization: none
  7. Message-ID: <828826575snz@genesis.demon.co.uk>
  8. References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca> <3162de71.18703379@news.ucs.ubc.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <3162de71.18703379@news.ucs.ubc.ca>
  15.            jamesdf@unixg.ubc.ca "James Fairweather" writes:
  16.  
  17. >>Any variable can be declared constant, including strings:
  18. >>
  19. >>       const char * const str = "Foo";
  20. >>
  21. >>Or do you mean literal constants?
  22. >>
  23. >I'm not sure what the difference is.  I thought the keyword "const"
  24. >was just for the compiler.  If you tried to modify the variable
  25. >declared const, the compiler would complain.  Does it do something
  26. >else with the variable if you declare it const?
  27.  
  28. It doesn't have to but it can legally put it (i.e. the pointer) in
  29. non-writable memory since the program can't legally write to it. The compiler
  30. can always put a string literal in non-writable memory since the program can
  31. never legally write to one.
  32.  
  33. -- 
  34. -----------------------------------------
  35. Lawrence Kirby | fred@genesis.demon.co.uk
  36. Wilts, England | 70734.126@compuserve.com
  37. -----------------------------------------
  38.